package main

import "fmt"

func main() {
	a := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9} // 底层数组

	// 新切片
	s1 := a[2:5]            // [2, 5)
	fmt.Println("s1 =", s1) // s1 = [2 3 4]

	// s2基于s1切
	s2 := s1[0:5]           // [2, 5)
	fmt.Println("s2 =", s2) // s2 = [2 3 4 5 6]

	//fmt.Println(s2[6])	// panic: runtime error: index out of range [6] with length 5

	fmt.Printf("%p\n", &s1) // 0xc000008030
	fmt.Printf("%p", &s2)   // 0xc000008060 --> 地址也不同
}
